package cn.hank.controller;

import cn.hank.pojo.Account;
import cn.hank.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 账户的控制器
 * @author hank
 * @Company dakui
 * @Version 1.0
 */
@Controller("accountController")
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService accountService;


    @RequestMapping("/findAllAccount")
    public String findAllAccount() {
        System.out.println("执行了查询账户controller");
        List<Account> allAccount = accountService.findAllAccount();
        for (Account account:allAccount){
            System.out.println(account.toString());
        }
        return "success";
    }
    @RequestMapping("/save")
    public String save() {
        System.out.println("执行了查询账户controller");
        Account account=new Account();
        account.setName("hank");
        account.setMoney(10000f);
        accountService.saveAccount(account);

        return "success";
    }
}
